<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>

    
</head>
<body>
    <input type="text" id="ipt">
    <button id="btn">我是一个按钮</button>
    <script>
        const btn = document.querySelector('#btn')
        const ipt= document.querySelector('#ipt')

        const Axios1 = axios.create({
            baseURL:'/',
            timetou:10000,
            headers:{

            }
        })
        //加入请求拦截器
        Axios1.interceptors.request.use((config)=>{
            const token = 'ajsnjkbaskfjbskdjbfds.asnfkjnfjn.ajfbjisdfisd'
            return config
        },(err)=>{
            // console.log(err.message);
            return Promise.reject(err.message)
        })
        //加入响应拦截器
        Axios1.interceptors.response.use((res)=>{

            return res.data.data
        },(err)=>{
            return  Promise.reject(err.message)
        })
        btn.onclick =  async function (){
           try{
            const valueA = ipt.value
            const A = await Axios1.post('/user',{
                name :valueA
            })
            console.log(A);
           }catch(e){
            console.log(e.message);
           }
        }

    </script>
</body>
</html>